import 'package:eleapp/res/strings.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// 引入三个页面
import './home.dart';
import './camera.dart';
import './personal.dart';

// ignore: must_be_immutable
class Tabs extends StatefulWidget {
  // 定义存储路由传参的变量
  // final Map arguments;
  int tabindex;
  Tabs({super.key, this.tabindex = 0});

  @override
  State<Tabs> createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  late int currentindex;
  List pagelist = const [Home(), Camera(), Personal()];
  // List pagename = [
  //   StringStyles.home.tr,
  //   StringStyles.score.tr,
  //   StringStyles.mine.tr
  // ];

  @override
  void initState() {
    super.initState();
    // currentindex = widget.arguments;
    // ignore: avoid_print
    currentindex = widget.tabindex;
  }

  @override
  Widget build(BuildContext context) {
    List pagename = [
      StringStyles.home.tr,
      StringStyles.score.tr,
      StringStyles.mine.tr
    ];

    return Scaffold(
      appBar: AppBar(
        title: Text(
          pagename[currentindex],
          style: const TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.blue,
        // leading: const Icon(Icons.menu),
      ),
      body: pagelist[currentindex],
      bottomNavigationBar: BottomNavigationBar(
        fixedColor: Colors.red,
        currentIndex: currentindex,
        items: [
          BottomNavigationBarItem(
              icon: const Icon(Icons.home), label: StringStyles.home.tr),
          BottomNavigationBarItem(
              icon: const Icon(Icons.camera_alt), label: StringStyles.score.tr),
          BottomNavigationBarItem(
              icon: const Icon(Icons.person_2_outlined),
              label: StringStyles.mine.tr),
        ],
        onTap: (value) {
          setState(() {
            currentindex = value;
          });
        },
      ),
    );
  }
}
